package api

import (
	"api-gateway/basic/config"
	__ "api-gateway/basic/proto"
	"api-gateway/handler/request"
	"github.com/gin-gonic/gin"
	"net/http"
)

func Datilyadd(context *gin.Context) {
	var l request.DatilyAdd
	if err := context.ShouldBind(&l); err != nil {
		context.JSON(400, gin.H{
			"code": 400,
			"msg":  "验证失败",
			"data": err.Error(),
		})
		return

	}
	r, err := config.AppointmentClient.DailyReserveStockAdd(config.Ctx, &__.DailyReserveStockAddReq{
		HospitalId:     l.HospitalId,
		PackageId:      l.PackageId,
		TotalStock:     l.TotalStock,
		UsedStock:      l.UsedStock,
		RemainingStock: l.RemainingStock,
		Status:         l.Status,
	})
	if err != nil {
		context.JSON(400, gin.H{
			"code": 400,
			"msg":  "账号禁用",
			"data": err.Error(),
		})
		return
	}
	context.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "预约成功",
		"data": r.Id,
	})
}
